﻿using System;
using System.Configuration;
using System.Web;
using System.Data.Linq;
using System.Linq;
using DentScan2.DB;

namespace DentScan2.WebApp.Handlers
{
    public class DetailImageHandler : IHttpHandler
    {
        protected DLDataContext dl = new DLDataContext(ConfigurationManager.ConnectionStrings["DBCONN"].ConnectionString);

        /// <summary>
        /// You will need to configure this handler in the Web.config file of your 
        /// web and register it with IIS before being able to use it. For more information
        /// see the following link: http://go.microsoft.com/?linkid=8101007
        /// </summary>
        #region IHttpHandler Members

        public bool IsReusable
        {
            // Return false in case your Managed Handler cannot be reused for another request.
            // Usually this would be false in case you have some state information preserved per request.
            get { return true; }
        }

        public void ProcessRequest(HttpContext context)
        {            
            context.Response.Clear();
            if (context.Session["CurrentImage"]!=null)
                context.Response.BinaryWrite(context.Session["CurrentImage"] as byte[]);
            context.Response.End();
        }

        #endregion
    }
}
